<?php
/**
 * Created by PhpStorm.
 * User: lenovo
 * Date: 2018/4/28
 * Time: 17:20
 */

namespace app\common\model;


use think\Db;
use think\Model;

class Type extends Model{

    /**种类列表
     * @return bool|\think\Paginator
     */
    public function index()
    {
        $list = Db::name('type')->alias('t')
            ->join('floor f','t.fid = f.id', 'LEFT')
            ->field(['t.id', 't.type', 't.fid', 't.long', 't.wide', 't.num', 'f.name as f_name',  't.create_time', 't.update_time'])
            ->order('t.id desc')
            ->paginate(15);
        if (sizeof($list) == 0) {
            return false;
        }
        return $list;
    }
    //根据分类ID 查找分类下面的种类
    public function getTypeForFloor($fid)
    {
        $typelist = Db::name('type')->where('fid', $fid)->field(['id', 'name'])->select();
        return $typelist;
    }

    /**
     * 前台获取不同类型下面   的尺寸
     */
    public function getFloorSize($fid)
    {
        return Db::name('type')->where('fid', $fid)->field(['id','type', 'num', 'long', 'wide'])->select();
    }



}